import Vue from 'vue'
Vue.prototype.$veriUrl = 'https://veri.yoojet.com' // 实名
var baseUrl = Vue.prototype.$veriUrl
const request = (type, url, data) => {
	return new Promise((resolve, reject) => {
		uni.request({
			method: type,
			url: baseUrl + url,
			data: data,
			header: {
				'Content-Type': 'application/json', //配置请求头
				'Authorization': uni.getStorageSync('vtoken')
			},
			dataType: 'json',
		}).then((response) => {
			let [error, res] = response;
			if (error !== null) {
				uni.showToast({
					title: '请求失败请检查网络或重试',
					icon: "none"
				});
				uni.hideLoading();
				return reject(error)
			}
			uni.hideLoading();
			resolve(res.data);
		}).catch(error => {
			Vue.prototype.$httpstate = true
			let [err, res] = error;
			console.log(err, res)
			reject(err)

		})
	});
}
export default request
